<?php
/**
 * Created by PhpStorm.
 * User: XJX
 * Date: 14-4-20
 * Time: ����11:09
 */
namespace Home\Controller;
use Think\Controller;
class ActivityController extends Controller {
    public function index(){
        $activity = D('Activity');
        $list = $activity->field('content',true)->order('id desc')->select();
        $resource = D('Resource');
        foreach ($list as &$v) {
            $r = $resource->where('id=%d', $v['pid'])->find();
            $v['path'] = $r['path'];
            $v['href'] = U('view',array('id'=>$v['id']));
        }
        $this->assign('list', $list);
        $this->display('./Public/activity.html');
    }

    public function view($id) {
        $activity = D('Activity');
        $result = $activity->where("id=$id")->find();
        $this->assign('content', htmlspecialchars_decode(stripslashes($result['content'])));
        $this->display('./Public/subview.html');
    }
}